package com.atguigu.service.impl;

import com.atguigu.base.BaseDao;
import com.atguigu.base.BaseServiceImpl;
import com.atguigu.dao.UserFollowDao;
import com.atguigu.entity.UserFollow;
import com.atguigu.service.UserFollowService;
import com.atguigu.vo.UserFollowVo;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;


@DubboService
public class UserFollowServiceImpl extends BaseServiceImpl<UserFollow> implements UserFollowService {

    @Autowired
    private UserFollowDao userFollowDao;

    @Override
    public UserFollow findByUserIdAndHouseId(Long userId, Long houseId) {
        return userFollowDao.findByUserIdAndHouseId(userId, houseId);
    }

    @Override
    public PageInfo<UserFollowVo> findListPage(Integer pageNum, Integer pageSize, Long userId) {
        //1.开启分页
        PageHelper.startPage(pageNum, pageSize);
        //2.调用持久层的方法查询当前用户的关注列表
        Page<UserFollowVo> userFollowVoList = userFollowDao.findListPage(userId);

        return new PageInfo<>(userFollowVoList, 5);
    }

    @Override
    protected BaseDao<UserFollow> getEntityDao() {
        return userFollowDao;
    }
}
